package cn.wolfcode.wms.web.interceptor;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.web.servlet.handler.HandlerInterceptorAdapter;

import cn.wolfcode.wms.domain.Employee;
import cn.wolfcode.wms.util.UserContext;

public class CheckLoginInterceptor extends HandlerInterceptorAdapter{

	
	@Override
	public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception {
		
		Employee currentUser = UserContext.getUser();
		if (currentUser==null) {
			response.sendRedirect("/login.jsp");
			return false;
		}
		return true;
	}
	
}
